package org.third.integration.http;

import org.apache.tomcat.util.buf.UDecoder;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class UrlCodeTest {
    
    public static void main(String[] args) {
        String src="cdeR(*#@)!dw*&~!%$+-{}[]>,.?中e1 _pdsfsd</";
//        cdeR%28*%23%40%29%21dw*%26%7E%21%25%24%2B-%7B%7D%5B%5D%3E%2C.%3F%E4%B8%ADe1+_pdsfsd%3C%2F
//        cdeR%28*%23%40%29%21dw*%26%7E%21%25%24%2B-%7B%7D%5B%5D%3E%2C.%3F%E4%B8%ADe1+_pdsfsd%3C%2F

        try {
            System.out.println(URLEncoder.encode(src, "UTF-8"));
            String encoded="cdeR%28*%23%40%29%21dw*%26%7E%21%25%24%2B-%7B%7D%5B%5D%3E%2C.%3F%E4%B8%ADe1+_pdsfsd%3C%2F";
            System.out.println(URLDecoder.decode(encoded,"UTF-8"));
            
            
            
            org.apache.tomcat.util.buf.UDecoder tomcatUDecoder = new UDecoder();
//            tomcatUDecoder.ALLOW_ENCODED_SLASH=true;
            System.out.println(tomcatUDecoder.convert(encoded, false));
            
            
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }

}
